home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wics.zip / PRINTER.H < prev    next >
C/C++ Source or Header  |  1993-03-05  |  7KB  |  210 lines

  1. //==============================================================================================
  2. //
  3. //    Windows Interface Construction Set
  4. //    Version 1.00
  5. //
  6. //    PRINTER.H - Windows Printing Classes
  7. //
  8. //    Copyright ⌐ 1993 by Microdyne Development Technologies
  9. //    All rights reserved.
  10. //
  11. //==============================================================================================
  12.  
  13. #ifndef __PRINTER_H
  14. #define __PRINTER_H
  15.  
  16. #include <owl.h>
  17. #include <objstrm.h>
  18. #include <owldefs.h>
  19. #include <tcollect.h>
  20. #include <static.h>
  21. #include <dlgtmplt.h>
  22. #include <idlg.h>
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. #include <drivinit.h>
  29. #include <string.h>
  30.  
  31. #ifdef __cplusplus
  32. }
  33. #endif
  34.  
  35. //    TPrinter status codes
  36.  
  37. #define PSTAT_OK              0
  38. #define PSTAT_INVALIDDEVICE -1        // Device parameters (to set device) invalid
  39. #define PSTAT_UNASSOCIATED     -2        // Object not associated with a printer
  40.  
  41. //    TPrintedPage banding flags
  42.  
  43. #define PFUNC_GRAPHICS        0x01    // Current band only accepts graphics
  44. #define PFUNC_TEXT            0x02    // Current band only accepts text
  45. #define PFUNC_BOTH            0x03    // Current band accepts both text and graphics
  46.  
  47. typedef WORD (FAR PASCAL *PTDeviceModeFcn)(HWND, HANDLE, LPSTR, LPSTR);
  48.  
  49. /*------------------------------------------------------------------------------------------*/
  50. /*    Classs TPrintedPage                                                                        */
  51. /*------------------------------------------------------------------------------------------*/
  52. /*                                                                                          */
  53. /*    Abstract:                                                                                */
  54. /*                                                                                          */
  55. /*    TPrintedPage represents the physical printed document which is to be sent to a printer    */
  56. /*    to be printed. TPrintedPage does the rendering of the document onto the printer. For    */
  57. /*    every document, or document type, a corresponding TPrintedPage class should be created. */
  58. /*                                                                                          */
  59. /*------------------------------------------------------------------------------------------*/
  60.  
  61. _CLASSDEF(TPrintedPage)
  62.  
  63. class TPrintedPage : public TStreamable
  64. {
  65. protected:
  66.     Pchar    Title;
  67.     POINT    ScreenDpi;
  68.  
  69. public:
  70.     TPrintedPage(Pchar ATitle);
  71.     virtual ~TPrintedPage();
  72.  
  73.     virtual void  PrintPage(HDC hdc, WORD Page, POINT Size, POINT dpi) {};
  74.     virtual BOOL  IsNextPage();
  75.     virtual Pchar GetTitle()   { return Title; }
  76.     virtual int   GetMaxPage() { return -1; }
  77.  
  78. private:
  79.     virtual const Pchar streamableName() const { return "TPrintedPage"; }
  80.  
  81. protected:
  82.     virtual Pvoid read(Ripstream) { return this; }
  83.     virtual void write(Ropstream) {}
  84.     virtual int GetPointSize (LOGFONT FAR * lplf);
  85. };
  86.  
  87. /*------------------------------------------------------------------------------------------*/
  88. /*    Class TPrinter                                                                            */
  89. /*------------------------------------------------------------------------------------------*/
  90. /*                                                                                          */
  91. /*    Abstract:                                                                               */
  92. /*                                                                                          */
  93. /*    TPrinter represents the physical printer device. To print a TPrintedPage, send the        */
  94. /*    TPrintedPage to the TPrinter's Print function.                                          */
  95. /*                                                                                          */
  96. /*------------------------------------------------------------------------------------------*/
  97.  
  98. _CLASSDEF(TPrinter)
  99.  
  100. class TPrinter: public TStreamable
  101. {
  102. private:
  103.     int                Status;                 
  104.     int                Error;                  
  105.     HANDLE            hDevNames;
  106.     HANDLE            hDevMode;
  107.     HINSTANCE        DeviceModule;
  108.     PTDeviceModeFcn    DeviceMode;
  109.     LPFNDEVMODE        ExtDeviceMode;
  110.     int                DevSettingSize;
  111.     BOOL            fUserAbort;
  112.     HDC              PrnDC;
  113.     WORD              Flags;
  114.     POINT             PageSize;
  115.     POINT             dpi;
  116.     BOOL            fBefore31;
  117.  
  118.     virtual const Pchar streamableName() const { return "TPrinter"; }
  119.  
  120. protected:
  121.     virtual Pvoid read(Ripstream) { return this; }
  122.     virtual void write(Ropstream) {}
  123.  
  124. public:
  125.     TPrinter();
  126.     virtual ~TPrinter();
  127.  
  128.     void ClearDevice();
  129.     void Configure(PTWindowsObject Window);
  130.     virtual HDC GetDC(PTWindowsObject ParentWin, Rint n, Rint nFromPage, Rint nToPage);
  131.     virtual void ReportError(PTWindowsObject ParentWin, PTPrintedPage Printout);
  132.     void SetDevice();
  133.     BOOL Print(PTWindowsObject ParentWin, PTPrintedPage Printout);
  134. };
  135.  
  136. /*------------------------------------------------------------------------------------------*/
  137. /*    Class TPrinterAbortDlg                                                                    */
  138. /*------------------------------------------------------------------------------------------*/
  139. /*                                                                                          */
  140. /*    Abstract:                                                                               */
  141. /*                                                                                          */
  142. /*    TPrinterAbortDlg represents the "printing" dialog box that is displayed while TPrinter    */
  143. /*    is printing a TPrintedPage.                                                                */
  144. /*                                                                                          */
  145. /*------------------------------------------------------------------------------------------*/
  146.  
  147. #define ID_TITLE        101
  148. #define ID_DEVICE        102
  149. #define ID_PORT            103
  150. #define ID_PAGEOFPAGE    104
  151.  
  152. _CLASSDEF(TPrinterAbortDlg)
  153.  
  154. class TPrinterAbortDlg: public TIndirectDialog
  155. {
  156. private:
  157.     BOOL FAR *            pfUserAbort;
  158.     Pchar                ATitle;
  159.     LPSTR                ADevice;
  160.     LPSTR                APort;
  161.     int                    MaxPage;
  162.     int                    CurrentPage;
  163.  
  164. protected:
  165.     virtual void WMCommand(RTMessage) = [WM_FIRST + WM_COMMAND];
  166.  
  167. public:
  168.     TPrinterAbortDlg(PTWindowsObject AParent, PTDialogTemplate ADialogTemplate, Pchar Title, LPSTR Device, LPSTR Port, BOOL& fUserAbort);
  169.     ~TPrinterAbortDlg();
  170.  
  171.     virtual void SetupWindow();
  172.  
  173.     virtual void SetMaxPage (int p);
  174.     virtual void SetCurrentPage (int p);
  175. };
  176.  
  177. /*------------------------------------------------------------------------------------------*/
  178. /*    Class TPrinterErrorDlg                                                                    */
  179. /*------------------------------------------------------------------------------------------*/
  180. /*                                                                                          */
  181. /*    Abstract:                                                                               */
  182. /*                                                                                          */
  183. /*    TPrinterErrorDlg represents the "Printer Error" dialog box that is displayed when         */
  184. /*    TPrinter detects an error.                                                                */
  185. /*                                                                                          */
  186. /*------------------------------------------------------------------------------------------*/
  187.  
  188. _CLASSDEF(TPrinterErrorDlg)
  189.  
  190. class TPrinterErrorDlg: public TIndirectDialog
  191. {
  192. private:
  193.  
  194. protected:
  195.  
  196. public:
  197.     TPrinterErrorDlg(PTWindowsObject AParent, PTDialogTemplate ADialogTemplate)
  198.         : TIndirectDialog (AParent, ADialogTemplate) {}
  199.     ~TPrinterErrorDlg() {}
  200.  
  201.     virtual void SetupWindow()
  202.         {
  203.             TIndirectDialog::SetupWindow();
  204.             SendDlgItemMsg (102, STM_SETICON, LoadIcon(NULL, IDI_HAND), 0L);
  205.         }
  206.  
  207. };
  208.  
  209. #endif
  210.